let mixin = {
  data() {
    return {
      autoHeight:
        document.documentElement.clientHeight || document.body.clientHeight,
    };
  },
  mounted() {
    const that = this;
    window.onresize = () => {
      return (() => {
        window.autoHeight = document.documentElement.clientHeight;
        that.autoHeight = window.autoHeight;
      })();
    };
  },
  methods: {
    notify(error) {
      if (error) {
        let errText = error;
        if (error.response && error.response.data) {
          errText = error.response.data.error;
        }
        this.$mg_notify({
          autoClose: true, //是否自动关闭
          autoCloseTime: window.app.config.ACTION_NOTIFY, //提示时长
          title: this.$t("global.text.error"), //提示标题
          content: errText, // 报错文本
        });
      } else {
        this.$mg_notify({
          autoClose: true,
          autoCloseTime: window.app.config.ACTION_NOTIFY, //提示时长
          title: this.$t("global.text.success")
        });
      }
    },
    // 时间日期格式时分秒
    formatterDateTime: function(data, arr) {
      let date = new Date(data);
      let datetime = "";
      if (arr) {
        datetime =
          date.getFullYear() +
          "-" + // "年"
          (date.getMonth() + 1 < 10
            ? "0" + (date.getMonth() + 1)
            : date.getMonth() + 1) +
          "-" + // "月"
          (date.getDate() < 10 ? "0" + date.getDate() : date.getDate());
      } else {
        datetime =
          date.getFullYear() +
          "-" + // "年"
          (date.getMonth() + 1 < 10
            ? "0" + (date.getMonth() + 1)
            : date.getMonth() + 1) +
          "-" + // "月"
          (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) +
          " " +
          (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) +
          ":" +
          (date.getMinutes() < 10
            ? "0" + date.getMinutes()
            : date.getMinutes()) +
          ":" +
          (date.getSeconds() < 10
            ? "0" + date.getSeconds()
            : date.getSeconds());
      }
      return datetime;
    },
  },
};
export default mixin;
